NotEmptyMap
@Serializable(with = NotEmptyMapSerializer::class)
@Since(version = KotoolsTypesVersion.V4_0_0)
Represents a map that has at least one entry, with a key of type K and a value of type V.
You can use the notEmptyMapOf or the toNotEmptyMap functions for creating an instance of this type.
Serialization and deserialization
The serialization and deserialization processes of this type behave like for the Map type.
Here's an example of Kotlin code that encodes and decodes this type using the JavaScript Object Notation (JSON) format from kotlinx.serialization:
val map: NotEmptyMap<Char, Int> = notEmptyMapOf('a' to 1, 'b' to 2)
val encoded: String = Json.encodeToString(map)
println(encoded) // {"a":1,"b":2}
val decoded: NotEmptyMap<Char, Int> = Json.decodeFromString(encoded)
println(decoded == map) // true
Content copied to clipboard
Types
Link copied to clipboard
object Companion
Contains static declarations for the NotEmptyMap type.
Properties
Link copied to clipboard
All keys of this map.
Link copied to clipboard
The size of this map.
Link copied to clipboard
All entries of this map except the first one.
Link copied to clipboard
All values of this map.